﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ page import="javax.servlet.http.Cookie"%>
<%@page import="java.net.URLDecoder"%>
<% 
String path = request.getContextPath(); //解決跳轉后樣式丟失的問題
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台登录</title>
	<link rel="stylesheet" href="<%=path%>/background/style/css/bootstrap.min.css">
	<link rel="stylesheet" href="<%=path%>/background/style/css/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/background/style/css/sweetalert.css"/>
	<link rel="stylesheet" type="text/css" href="<%=path%>/background/style/css/demo.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/background/style/css/login.css">
	<script type="text/javascript" src="<%=path%>/background/style/resource/Js/jquery.js"></script>
	<script type="text/javascript" src="<%=path%>/background/style/js/sweetalert.min.js" ></script>
	<script src="<%=path%>/background/style/js/sweetalert-dev.js"></script>
	<script src="<%=path%>/background/style/js/login.js"></script>
	<%!
		String name="";
		String pass="";
	%>
	<%
		Cookie[] cookies = request.getCookies();
		if (cookies != null) {
			for (int i = 0; i < cookies.length; i++) {
				if ("name".equals(cookies[i].getName())) {
					name = URLDecoder.decode(cookies[i].getValue(), "UTF-8");//解决中文乱码
				} else if ("pass".equals(cookies[i].getName())) {
					pass = cookies[i].getValue();
				}
				System.out.println(name);
			}
		}
		System.out.println(name);
		System.out.println(pass);
	%>
</head>
<body>
	<center>
		<h1><strong>小小淘后台管理</strong></h1>
	</center>
	<div class="demo" style="padding: 10px 0;">
		<div class="container">
			<div class="row">
				<div class="col-md-offset-3 col-md-6">
					<form action="<%=request.getContextPath()%>/user/login" onsubmit="return val_login()" class="form-horizontal" method="post">
						<span class="heading">用户登录</span>
						<span  id="message" style="color:red;display:none;">${msg}</span>
						<div class="form-group">
							<input type="text" class="form-control" name="name" id="inputUser3" value="<%=name%>" placeholder="用户名">
							<i class="fa fa-user"></i>
						</div>
						<div class="form-group help">
							<input type="password" class="form-control" name="pass" id="inputPassword3" value="<%=pass%>" placeholder="密　码">
							<i class="fa fa-lock"></i>
							<!-- <a href="#" class="fa fa-question-circle"></a> -->
						</div>
						<div class="form-group" >
							<select class="form-control" name="hasStore">
								<option value="0">管理员</option>
								<option value="1">商家</option>
							</select>
							 <i class="fa fa-user"></i>
						</div>
							<div class="form-group">
							<div class="main-checkbox">
								<input type="checkbox"  id="checkbox1" value="on" name="check">
								<label for="checkbox1"></label>
							</div>
								<span class="text">记住账号</span>
								<input type="submit" class="btn btn-default" value="登录"/>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	<script type="text/javascript">
		$(function(){
			var msg=$("#message").html();
			//alert(msg)
			if(msg!=""&&msg!=null){
				swal("登录失败!", msg, "error");	
			}
		});
	</script>
	</body>
	
</html>
